Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
Why am I getting "Property 'wide' does not exist on type 'ThemedStyledProps<PressableProps & RefAttributes<View>, DefaultTheme>'."

I'm trying to add styled components to my project, but I'm having some trouble changing the style based on the props of the styled component. Whenever I try to do this - width: ${(props) => (props.wide ? '100%' : undefined)}; I get a Property 'wide' does not exist on type 'ThemedStyledProps<PressableProps & RefAttributes<View>, DefaultTheme>'. error.

I'm passing variant, wide and style to the styled component and I have the props type defined like this:

type StyledPressableProps = {
    variant?: ButtonVariant;
    wide?: boolean;
} & PressableProps;

But I'm still getting a TS error.

My code:

import React, { FunctionComponent } from 'react';
import { PressableProps, ViewStyle, StyleProp } from 'react-native';
import styled from 'styled-components/native';

import colors from '@src/core/colors';
import HeaderText from '../Text/HeaderText';

type ButtonVariant = 'primary' | 'secondary' | 'tertiary';

type Props = {
    title: string;
    variant?: ButtonVariant;
    wide?: boolean;
    style?: StyleProp<ViewStyle>;
} & Omit<PressableProps, 'style'>;

type StyledPressableProps = {
    variant?: ButtonVariant;
    wide?: boolean;
} & PressableProps;

const PrimaryButton: FunctionComponent<Props> = ({ title, variant = 'primary', wide = false, ...rest }) => {
    const textColor = variant === 'primary' ? colors.white : colors.primary600;

    return (
        <StyledPressable
            variant={variant}
            wide={wide}
            style={({ pressed: isPressed }) => [{ elevation: isPressed ? 5 : 0 }]}
            {...rest}
        >
            <StyledHeaderText variant="h4" style={{ color: textColor }}>
                {title}
            </StyledHeaderText>
        </StyledPressable>
    );
};

const StyledPressable: FunctionComponent<StyledPressableProps> = styled.Pressable`
    padding: 12px 24px;
    border-radius: 100px;
    border-width: 1.5px;
    justify-content: center;
    align-items: center;
    align-self: center;
    width: ${(props) => (props.wide ? '100%' : undefined)};
    background-color: ${(props) => styles[props.variant].backgroundColor};
    border-color: ${(props) => styles[props.variant].borderColor};
`;

const StyledHeaderText = styled(HeaderText)`
    text-align: center;
`;

const styles = {
    primary: {
        backgroundColor: colors.primary600,
        borderColor: colors.primary600,
    },
    secondary: {
        backgroundColor: colors.white,
        borderColor: colors.primary600,
    },
    tertiary: {
        backgroundColor: 'transparent',
        borderColor: 'transparent',
    },
};

export default PrimaryButton;
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda